# g1=(i for i in range(10))
# while True:
#     try:
#         item=next(g1)
#         print(item)
#     except StopIteration:
#         break
#
# g2=(i for i in range(10) if i % 2 == 0)
# for i in g2:
#     print(i)
#
# def g3(n):
#     for i in range(n):
#         if i % 2 == 1:
#             yield i
# for i in g3(10):
#     print(i)

class Node:
    def __init__(self,item):
        self.item=item
        self.next=None
class Stack:
    def __init__(self):
        self.head=None
    def push(self,item):
        node=Node(item)
        node.next=self.head
        self.head=node
stack=Stack()
stack.push('a')
stack.push('b')
stack.push('c')
def stackGenerate(stack):
    cursor=stack.head
    while cursor != None:
        yield cursor.item
        cursor=cursor.next
g4=stackGenerate(stack)
while True:
    try:
        item=next(g4)
        print(item)
    except StopIteration:
        break
g5=stackGenerate(stack)
for item in g5:
    print(item)
